<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="联系电话" prop="mobile">
        <el-input
          v-model="queryParams.mobile"
          placeholder="请输入联系电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系人" prop="realname">
        <el-input
          v-model="queryParams.realname"
          placeholder="请输入联系人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="店铺名称" prop="shopname">
        <el-input
          v-model="queryParams.shopname"
          placeholder="请输入店铺名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="店铺位置" prop="shopLocation" v-has-role="['admin','messageSender','insideWorker']">
        <el-cascader
          :options="options"
          v-model="selectedOptions"
          @change="handleRegionChange">
        </el-cascader>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['smy:merchant:add']"
        >新增</el-button>
      </el-col>
<!--      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
    </el-row>

    <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
<!--      <el-table-column type="selection" width="55" align="center" />-->
<!--      <el-table-column label="${comment}" align="center" prop="id" />-->
      <el-table-column label="账号" align="center" prop="username" />
      <el-table-column label="店铺名称" align="center" prop="shopname" />
      <el-table-column label="联系人" align="center" prop="realname" />
      <el-table-column label="联系电话" align="center" prop="mobile" />
      <el-table-column label="入驻时间" align="center" prop="merchantentertime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.merchantentertime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
<!--      <el-table-column label="在售商品数" align="center" prop="goodsnumber" />-->
<!--      <el-table-column label="总成交金额" align="center" prop="totalorderamount" />-->
<!--      <el-table-column label="总成交笔数" align="center" prop="totalordernumber" />-->
      <el-table-column label="商家状态" align="center" prop="accountnonlocked" width="80">
        <template slot-scope="scope">
          <span v-if="scope.row.accountnonlocked===0" style="font-weight: bold;color: red">停用</span>
          <span v-if="scope.row.accountnonlocked===1">启用</span>
        </template>
      </el-table-column>
      <el-table-column label="铺酒状态" align="center" prop="accountnonlocked" width="100">
        <template slot-scope="scope">
          <span v-if="scope.row.hasWine==='Y'">已铺酒</span>
          <span v-else>未铺酒</span>
        </template>
      </el-table-column>


<!--      <el-table-column label="${comment}" align="center" prop="avatar" />-->
<!--      <el-table-column label="${comment}" align="center" prop="createtime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.createtime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="${comment}" align="center" prop="lastlogintime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.lastlogintime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="${comment}" align="center" prop="loginip" />-->

<!--      <el-table-column label="${comment}" align="center" prop="nickname" />-->
<!--      <el-table-column label="${comment}" align="center" prop="password" />-->
<!--      <el-table-column label="${comment}" align="center" prop="realname" />-->
<!--      <el-table-column label="${comment}" align="center" prop="refreshtoken" />-->
<!--      <el-table-column label="${comment}" align="center" prop="username" />-->
<!--      <el-table-column label="${comment}" align="center" prop="roleId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="email" />-->
<!--      <el-table-column label="${comment}" align="center" prop="maintype" />-->
<!--      <el-table-column label="${comment}" align="center" prop="merchantchecknote" />-->
<!--      <el-table-column label="${comment}" align="center" prop="merchantcheckstatus" />-->
<!--      <el-table-column label="${comment}" align="center" prop="qq" />-->
<!--      <el-table-column label="${comment}" align="center" prop="shopname" />-->

<!--      <el-table-column label="${comment}" align="center" prop="merchantentertime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.merchantentertime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->


<!--      <el-table-column label="${comment}" align="center" prop="wechat" />-->
<!--      <el-table-column label="${comment}" align="center" prop="merchantenterpriseinfoId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="merchantindividualinfoId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="merchantpersonalinfoId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="bankaccountholder" />-->
<!--      <el-table-column label="${comment}" align="center" prop="bankcardno" />-->
<!--      <el-table-column label="${comment}" align="center" prop="bankcity" />-->
<!--      <el-table-column label="${comment}" align="center" prop="bankmobile" />-->
<!--      <el-table-column label="${comment}" align="center" prop="bankname" />-->
<!--      <el-table-column label="${comment}" align="center" prop="bankprovince" />-->
<!--      <el-table-column label="${comment}" align="center" prop="banksubbranchname" />-->
<!--      <el-table-column label="${comment}" align="center" prop="signature" />-->
<!--      <el-table-column label="${comment}" align="center" prop="ordermessagenumber" />-->
<!--      <el-table-column label="${comment}" align="center" prop="systemmessagenumber" />-->
<!--      <el-table-column label="${comment}" align="center" prop="withdrawmessagenumber" />-->
<!--      <el-table-column label="${comment}" align="center" prop="openid" />-->
<!--      <el-table-column label="${comment}" align="center" prop="wechatsessionkey" />-->
<!--      <el-table-column label="${comment}" align="center" prop="firstlogintime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.firstlogintime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="${comment}" align="center" prop="warehouseaddress" />-->
<!--      <el-table-column label="${comment}" align="center" prop="sex" />-->
<!--      <el-table-column label="${comment}" align="center" prop="balance" />-->
<!--      <el-table-column label="${comment}" align="center" prop="userno" />-->
<!--      <el-table-column label="${comment}" align="center" prop="merchantinvoicetfn" />-->
<!--      <el-table-column label="${comment}" align="center" prop="merchantinvoicetitle" />-->
<!--      <el-table-column label="${comment}" align="center" prop="merchantinvoicetitletype" />-->
<!--      <el-table-column label="${comment}" align="center" prop="selfsupport" />-->
<!--      <el-table-column label="${comment}" align="center" prop="shopbanner" />-->
<!--      <el-table-column label="${comment}" align="center" prop="relevancememberId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="relevancemerchantId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="certificate" />-->
<!--      <el-table-column label="${comment}" align="center" prop="firstlogin" />-->
<!--      <el-table-column label="${comment}" align="center" prop="fatherId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="guaranteescale" />-->
<!--      <el-table-column label="${comment}" align="center" prop="distributorId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="modifyrealnametime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.modifyrealnametime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="${comment}" align="center" prop="anchorId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="fatherexpires" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.fatherexpires, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="${comment}" align="center" prop="modifynicknametime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.modifynicknametime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="${comment}" align="center" prop="liveidcardfront" />-->
<!--      <el-table-column label="${comment}" align="center" prop="liveidcardno" />-->
<!--      <el-table-column label="${comment}" align="center" prop="liveidcardreverse" />-->
<!--      <el-table-column label="${comment}" align="center" prop="livechecknote" />-->
<!--      <el-table-column label="${comment}" align="center" prop="livecheckstatus" />-->
<!--      <el-table-column label="${comment}" align="center" prop="liveid" />-->
<!--      <el-table-column label="${comment}" align="center" prop="liveimage" width="100">-->
<!--        <template slot-scope="scope">-->
<!--          <image-preview :src="scope.row.liveimage" :width="50" :height="50"/>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="${comment}" align="center" prop="liveintroduce" />-->
<!--      <el-table-column label="${comment}" align="center" prop="livename" />-->
<!--      <el-table-column label="${comment}" align="center" prop="livebalance" />-->
<!--      <el-table-column label="${comment}" align="center" prop="livecreatetime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.livecreatetime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="${comment}" align="center" prop="livestatus" />-->
<!--      <el-table-column label="${comment}" align="center" prop="livetype" />-->
<!--      <el-table-column label="${comment}" align="center" prop="liveSessionId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="unionid" />-->
<!--      <el-table-column label="${comment}" align="center" prop="scandistributorid" />-->
<!--      <el-table-column label="${comment}" align="center" prop="merchantlat" />-->
<!--      <el-table-column label="${comment}" align="center" prop="merchantlng" />-->
<!--      <el-table-column label="${comment}" align="center" prop="lowestprice" />-->
<!--      <el-table-column label="${comment}" align="center" prop="closehour" />-->
<!--      <el-table-column label="${comment}" align="center" prop="closeminutes" />-->
<!--      <el-table-column label="${comment}" align="center" prop="openhour" />-->
<!--      <el-table-column label="${comment}" align="center" prop="openminutes" />-->
<!--      <el-table-column label="${comment}" align="center" prop="shopstatus" />-->
<!--      <el-table-column label="${comment}" align="center" prop="worktime" />-->
<!--      <el-table-column label="${comment}" align="center" prop="ratestar" />-->
<!--      <el-table-column label="${comment}" align="center" prop="attituderatestar" />-->
<!--      <el-table-column label="${comment}" align="center" prop="lookratestar" />-->
<!--      <el-table-column label="${comment}" align="center" prop="tasteratestar" />-->
<!--      <el-table-column label="${comment}" align="center" prop="completenum" />-->
      <el-table-column label="排序" align="center" prop="rankno" width="80"/>

      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="360">
        <template slot-scope="scope">
          <el-button
            size="small"
            type="primary"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['smy:merchant:edit']"
          >修改</el-button>
          <el-button
            size="small"
            type="info"
            icon="el-icon-video-pause"
            @click="handleDisable(scope.row,'Y')"
            v-hasPermi="['smy:merchant:edit']"
            v-if="scope.row.accountnonlocked===1"
          >停用</el-button>
          <el-button
            size="small"
            type="info"
            icon="el-icon-video-pause"
            @click="handleDisable(scope.row,'N')"
            v-hasPermi="['smy:merchant:edit']"
            v-if="scope.row.accountnonlocked===1"
          >静默停用</el-button>
          <el-button
            size="small"
            type="warning"
            icon="el-icon-video-play"
            @click="handleEnable(scope.row,'Y')"
            v-hasPermi="['smy:merchant:edit']"
            v-if="scope.row.accountnonlocked===0"
          >启用</el-button>
          <el-button
            size="small"
            type="warning"
            icon="el-icon-video-play"
            @click="handleEnable(scope.row,'N')"
            v-hasPermi="['smy:merchant:edit']"
            v-if="scope.row.accountnonlocked===0"
          >静默启用</el-button>
          <el-button
            size="small"
            type="success"
            icon="el-icon-folder-checked"
            @click="handleSetWineStatus(scope.row,'Y')"
            v-hasPermi="['smy:merchant:setWineStatus']"
            v-if="scope.row.hasWine!=='Y'"
          >铺酒</el-button>
          <el-button
            size="small"
            type="warning"
            icon="el-icon-folder-delete"
            @click="handleSetWineStatus(scope.row,'N')"
            v-hasPermi="['smy:merchant:setWineStatus']"
            v-if="scope.row.hasWine==='Y'"
          >取消铺酒</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改【请填写功能名称】对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body :closeOnClickModal="false">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="联系电话" prop="mobile">
          <el-input v-model="form.mobile" placeholder="请输入联系电话" :disabled="this.form.id != null" />
        </el-form-item>
        <el-form-item label="联系人" prop="realname">
          <el-input v-model="form.realname" placeholder="请输入联系人姓名" :disabled="this.form.id != null" />
        </el-form-item>
        <el-form-item label="登录账号" prop="username">
          <el-input v-model="form.username" placeholder="请输入登录账号" :disabled="this.form.id != null" />
        </el-form-item>
        <el-form-item label="店铺名称" prop="shopname">
          <el-input v-model="form.shopname" placeholder="请输入店铺名称" :disabled="this.form.id != null" />
        </el-form-item>

<!--        <el-form-item label="${comment}" prop="ratestar">-->
<!--          <el-input v-model="form.ratestar" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="attituderatestar">-->
<!--          <el-input v-model="form.attituderatestar" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="lookratestar">-->
<!--          <el-input v-model="form.lookratestar" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="tasteratestar">-->
<!--          <el-input v-model="form.tasteratestar" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="completenum">-->
<!--          <el-input v-model="form.completenum" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
        <el-form-item label="店铺类型" prop="groupType">
          <el-select v-model="form.groupType" placeholder="请选择">
            <el-option
              v-for="item in groupTypeList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="店铺序号" prop="rankno">
          <el-input v-model="form.rankno" placeholder="请输入店铺序号"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listUser, getUser, delUser, addUser, updateUser,changeStatus,setWineStatus } from "@/api/smy/merchant";
import { provinceAndCityData, regionData, provinceAndCityDataPlus, regionDataPlus, CodeToText, TextToCode } from 'element-china-area-data'
export default {
  name: "User",
  data() {
    return {
      selectedOptions: [],
      options: regionDataPlus,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      userList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      groupTypeList:[
        {value: 'hotel', label: '酒店/住宿'},
        {value: 'restaurant', label: '饭店/餐饮'},
        {value: 'entertainment', label: '休闲/娱乐'},
      ],

      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        accesstoken: null,
        accountnonlocked: null,
        avatar: null,
        createtime: null,
        lastlogintime: null,
        loginip: null,
        mobile: null,
        nickname: null,
        password: null,
        realname: null,
        refreshtoken: null,
        username: null,
        roleId: null,
        email: null,
        maintype: null,
        merchantchecknote: null,
        merchantcheckstatus: null,
        qq: null,
        shopname: null,
        goodsnumber: null,
        merchantentertime: null,
        totalorderamount: null,
        totalordernumber: null,
        wechat: null,
        merchantenterpriseinfoId: null,
        merchantindividualinfoId: null,
        merchantpersonalinfoId: null,
        bankaccountholder: null,
        bankcardno: null,
        bankcity: null,
        bankmobile: null,
        bankname: null,
        bankprovince: null,
        banksubbranchname: null,
        signature: null,
        ordermessagenumber: null,
        systemmessagenumber: null,
        withdrawmessagenumber: null,
        openid: null,
        wechatsessionkey: null,
        firstlogintime: null,
        warehouseaddress: null,
        sex: null,
        balance: null,
        userno: null,
        merchantinvoicetfn: null,
        merchantinvoicetitle: null,
        merchantinvoicetitletype: null,
        selfsupport: null,
        shopbanner: null,
        relevancememberId: null,
        relevancemerchantId: null,
        certificate: null,
        firstlogin: null,
        fatherId: null,
        guaranteescale: null,
        distributorId: null,
        modifyrealnametime: null,
        anchorId: null,
        fatherexpires: null,
        modifynicknametime: null,
        liveidcardfront: null,
        liveidcardno: null,
        liveidcardreverse: null,
        livechecknote: null,
        livecheckstatus: null,
        liveid: null,
        liveimage: null,
        liveintroduce: null,
        livename: null,
        livebalance: null,
        livecreatetime: null,
        livestatus: null,
        livetype: null,
        liveSessionId: null,
        unionid: null,
        scandistributorid: null,
        merchantlat: null,
        merchantlng: null,
        lowestprice: null,
        closehour: null,
        closeminutes: null,
        openhour: null,
        openminutes: null,
        shopstatus: null,
        worktime: null,
        ratestar: null,
        attituderatestar: null,
        lookratestar: null,
        tasteratestar: null,
        completenum: null,
        rankno: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        mobile: [
          { required: true, message: "联系电话不能为空", trigger: "blur" },

        ],
        username: [
          { required: true, message: "登录账号不能为空", trigger: "blur" }
        ],

        realname: [
          { required: true, message: "联系人不能为空", trigger: "blur" }
        ],
        shopname: [
          { required: true, message: "店铺名称不能为空", trigger: "change" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      listUser(this.queryParams).then(response => {
        this.userList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    handleRegionChange(value){
      console.log(value);
      let provinceCode = value[0];
      let cityCode = value[1];
      let countyCode = value[2];
      if(provinceCode){
        this.queryParams.provinceName = CodeToText[provinceCode];
      }
      if(cityCode){
        this.queryParams.cityName = CodeToText[cityCode];
      }
      if(provinceCode && cityCode ===''){
        this.queryParams.cityName = "全部";
        this.queryParams.countyName = "全部";
      }
      if(countyCode){
        this.queryParams.countyName = CodeToText[countyCode];
      }
      if(provinceCode && countyCode === ''){
        this.queryParams.countyName = "全部";
      }
      console.log(this.queryParams);
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        accesstoken: null,
        accountnonlocked: null,
        avatar: null,
        createtime: null,
        lastlogintime: null,
        loginip: null,
        mobile: null,
        nickname: null,
        password: null,
        realname: null,
        refreshtoken: null,
        username: null,
        roleId: null,
        email: null,
        maintype: null,
        merchantchecknote: null,
        merchantcheckstatus: 0,
        qq: null,
        shopname: null,
        goodsnumber: null,
        merchantentertime: null,
        totalorderamount: null,
        totalordernumber: null,
        wechat: null,
        merchantenterpriseinfoId: null,
        merchantindividualinfoId: null,
        merchantpersonalinfoId: null,
        bankaccountholder: null,
        bankcardno: null,
        bankcity: null,
        bankmobile: null,
        bankname: null,
        bankprovince: null,
        banksubbranchname: null,
        signature: null,
        ordermessagenumber: null,
        systemmessagenumber: null,
        withdrawmessagenumber: null,
        openid: null,
        wechatsessionkey: null,
        firstlogintime: null,
        warehouseaddress: null,
        sex: null,
        balance: null,
        userno: null,
        merchantinvoicetfn: null,
        merchantinvoicetitle: null,
        merchantinvoicetitletype: null,
        selfsupport: null,
        shopbanner: null,
        relevancememberId: null,
        relevancemerchantId: null,
        certificate: null,
        firstlogin: null,
        fatherId: null,
        guaranteescale: null,
        distributorId: null,
        modifyrealnametime: null,
        anchorId: null,
        fatherexpires: null,
        modifynicknametime: null,
        liveidcardfront: null,
        liveidcardno: null,
        liveidcardreverse: null,
        livechecknote: null,
        livecheckstatus: 0,
        liveid: null,
        liveimage: null,
        liveintroduce: null,
        livename: null,
        livebalance: null,
        livecreatetime: null,
        livestatus: 0,
        livetype: null,
        liveSessionId: null,
        unionid: null,
        scandistributorid: null,
        merchantlat: null,
        merchantlng: null,
        lowestprice: null,
        closehour: null,
        closeminutes: null,
        openhour: null,
        openminutes: null,
        shopstatus: "0",
        worktime: null,
        ratestar: null,
        attituderatestar: null,
        lookratestar: null,
        tasteratestar: null,
        completenum: null,
        rankno: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      if(this.queryParams.provinceName==='全部'){
        this.queryParams.provinceName = "";
      }
      if(this.queryParams.cityName==='全部'){
        this.queryParams.cityName = "";
      }
      if(this.queryParams.countyName==='全部'){
        this.queryParams.countyName = "";
      }
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.selectedOptions =[];
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加合作商家";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getUser(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改商家信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateUser(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addUser(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    handleSetWineStatus(row,optType){
      const id = row.id;
      let optDto = {optId:id,optType}
      let message = "是否确认商家'"+row.shopname+"'";
      if(optType==='Y'){
        message+="已铺酒？"
      }
      if(optType==='N'){
        message+="已取消铺酒？"
      }
      this.$modal.confirm(message).then(function() {
        return setWineStatus(optDto);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("操作成功");
      }).catch(() => {});
    },
    handleDisable(row,ifMessage){
      const id = row.id;
      let optDto = {optId:id,optName:0,optType:ifMessage}
      this.$modal.confirm('是否确认停用名称为"' + row.shopname + '"的商家账号？').then(function() {
        return changeStatus(optDto);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("操作成功");
      }).catch(() => {});
    },
    handleEnable(row,ifMessage){
      const id = row.id;
      let optDto = {optId:id,optName:1,optType:ifMessage}
      this.$modal.confirm('是否确认启用名称为"' + row.shopname + '"的商家账号？').then(function() {
        return changeStatus(optDto);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("操作成功");
      }).catch(() => {});
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除【请填写功能名称】编号为"' + ids + '"的数据项？').then(function() {
        return delUser(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/user/export', {
        ...this.queryParams
      }, `user_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
